package com.wfy.pojo;

/**
 * @Title: SearchRequest
 * @Package com.wfy.pojo
 * @Author 王飞遥
 * @Date 2022/9/19 21:01
 */
public class SearchRequest {
    private String key; //搜索条件
    private Integer page;//当前页
    public static final int DEFAULT_SIZE=20; //每页大小 不从页面接收 而是固定大小
    public static final int DEFAULT_PAGE=1;//默认页
    private Integer size; //大小
    private String sortBy;//排序字段
    private Boolean descending;//是否降序

    public String getSortBy() {
        return sortBy;
    }

    public void setSortBy(String sortBy) {
        this.sortBy = sortBy;
    }

    public Boolean getDescending() {
        return descending;
    }

    public void setDescending(Boolean descending) {
        this.descending = descending;
    }

    public Integer getSize() {
        return DEFAULT_SIZE;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        if(page==null){
            return DEFAULT_PAGE ;
        }
        //获取页码时候的一些校验 不能小于1
        return Math.max(DEFAULT_PAGE,page);
    }

    public void setPage(Integer page) {
        this.page = page;
    }
}
